import Taro, { Component, Config } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtTabBar } from 'taro-ui'
import '../assets/css/active.scss'
import curtainPng from '../assets/images/curtain.png'
export default class Tabbar extends Component {
  constructor (props) {
    super(props)   // ✓ 正确
    this.state = {
        current: this.props.onCurrent
    }
  }
  componentWillMount () {
    
   }

  componentDidMount () {
   
  }

  componentWillUnmount () { 
   
  }

  componentDidShow () { }

  componentDidHide () { }
  handleClick (value) {
    this.setState({
      current: value
    })
    switch (value) {
      case 0:
          Taro.navigateTo({
              url: '/pages/index/index'
          })
          break;
      case 1:
          Taro.navigateTo({
              url: '/pages/home/index?userid=2'
          })
          break;
      case 2:
          Taro.redirectTo({
              url: `/pages/leading/leading`
          })
          break;
      case 3:
        Taro.navigateTo({
            url: '/pages/user/index'
        })
          break;            
      default:
          break;
    }    
  }
  render () {
    return (
      <View className='tabheight'>
            <AtTabBar fixed tabList={[
            { title: '首页', iconType: 'home'},
            { title: '搜索', iconType: 'search' },
            { title: '引导', iconType: 'folder'},
            { title: '我的', iconType: 'user'}
          ]}
          onClick={this.handleClick.bind(this)}
          current={this.state.current}
        />
      </View>
    )
  }
}
